package atguigu.lst;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Set<Boolean> booleanSet = new HashSet<>();

        // 添加一些值到集合中
        booleanSet.add(true);
        booleanSet.add(false);
        booleanSet.add(true);

        // 使用 Stream API 来检查集合中是否有任何 false 值
        boolean anyFalse = booleanSet.stream().anyMatch(b -> b);

        // 输出结果
        System.out.println("集合中是否有任何 true 值: " + anyFalse);

        // 检查 booleanSet 中是否所有的值都是 true
        boolean allTrue = booleanSet.stream().allMatch(b -> b);
        // 输出结果
        System.out.println("集合中是否所有的值都是 true: " + allTrue);

        List<CompResult> crs = new ArrayList<>();

        CompResult cr = new CompResult("温度", 1, 10, 12);
        crs.add(cr);

        cr = new CompResult("湿度", 2, 10, 15);
        crs.add(cr);

        List<Boolean> collect = crs.stream().map(e -> e.isExcepton()).collect(Collectors.toList());
        boolean b = collect.stream().anyMatch(e -> e);
        System.out.println("是否有异常:" + b);

        List<CompResult> nodes = crs.stream().filter(e -> e.isExcepton()).collect(Collectors.toList());
        StringBuilder sb = new StringBuilder();
        for (CompResult node : nodes) {
            sb.append(node);
        }
        System.out.println(sb.toString());

    }
}